package com.jiesai.amaq.canines.project.dogs.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jiesai.amaq.canines.framework.aspectj.lang.annotation.Log;
import com.jiesai.amaq.canines.framework.aspectj.lang.enums.BusinessType;
import com.jiesai.amaq.canines.project.dogs.domain.DogImmune;
import com.jiesai.amaq.canines.project.dogs.service.IDogImmuneService;
import com.jiesai.amaq.canines.framework.web.controller.BaseController;
import com.jiesai.amaq.canines.framework.web.domain.AjaxResult;
import com.jiesai.amaq.canines.common.utils.poi.ExcelUtil;
import com.jiesai.amaq.canines.framework.web.page.TableDataInfo;

/**
 * 城市犬只免疫登记Controller
 * 
 * @author admin
 * @date 2021-11-22
 */
@RestController
@RequestMapping("/dogs/immune")
public class DogImmuneController extends BaseController
{
    @Autowired
    private IDogImmuneService dogImmuneService;

    /**
     * 查询城市犬只免疫登记列表
     */
    @PreAuthorize("@ss.hasPermi('dogs:immune:list')")
    @GetMapping("/list")
    public TableDataInfo list(DogImmune dogImmune)
    {
        startPage();
        List<DogImmune> list = dogImmuneService.selectDogImmuneList(dogImmune);
        return getDataTable(list);
    }

    /**
     * 导出城市犬只免疫登记列表
     */
    @PreAuthorize("@ss.hasPermi('dogs:immune:export')")
    @Log(title = "城市犬只免疫登记", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DogImmune dogImmune)
    {
        List<DogImmune> list = dogImmuneService.selectDogImmuneList(dogImmune);
        ExcelUtil<DogImmune> util = new ExcelUtil<DogImmune>(DogImmune.class);
        return util.exportExcel(list, "城市犬只免疫登记数据");
    }

    /**
     * 获取城市犬只免疫登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('dogs:immune:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dogImmuneService.selectDogImmuneById(id));
    }

    /**
     * 新增城市犬只免疫登记
     */
    @PreAuthorize("@ss.hasPermi('dogs:immune:add')")
    @Log(title = "城市犬只免疫登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DogImmune dogImmune)
    {
        return toAjax(dogImmuneService.insertDogImmune(dogImmune));
    }

    /**
     * 修改城市犬只免疫登记
     */
    @PreAuthorize("@ss.hasPermi('dogs:immune:edit')")
    @Log(title = "城市犬只免疫登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DogImmune dogImmune)
    {
        return toAjax(dogImmuneService.updateDogImmune(dogImmune));
    }

    /**
     * 删除城市犬只免疫登记
     */
    @PreAuthorize("@ss.hasPermi('dogs:immune:remove')")
    @Log(title = "城市犬只免疫登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dogImmuneService.deleteDogImmuneByIds(ids));
    }
}
